import json
from models import BaseModels
from sqlalchemy import Column, String, BigInteger, ForeignKey, Float, Uuid, Boolean


class CraftInit(BaseModels):
    __tablename__ = 'craftinit'
    id = Column(BigInteger, autoincrement=True, primary_key=True, unique=True, nullable=False)
    ft_id = Column(BigInteger, ForeignKey("facility.id", ondelete="SET NULL"), comment="设备id")
    address = Column(String(64), nullable=False, comment="PLC地址变量")
    types = Column(String(64), nullable=False, comment="PLC地址变量数据类型")
    describe = Column(String(64), nullable=False, comment="PLC地址变量描述介绍")


class Craft(BaseModels):
    __tablename__ = 'craft'
    id = Column(BigInteger, autoincrement=True, primary_key=True, unique=True, nullable=False)
    facility_id = Column(BigInteger, ForeignKey("facility.id", ondelete="SET NULL"), comment="设备id")
    aircraft_id = Column(BigInteger, ForeignKey("aircraft.id", ondelete="SET NULL"), comment="机种数据库ID")
    address = Column(String(64), nullable=False, comment="PLC地址变量")
    types = Column(String(64), nullable=False, comment="PLC地址变量数据类型")
    describe = Column(String(64), nullable=False, comment="PLC地址变量描述介绍")
    write = Column(String(64), nullable=True, comment="设备参数写入值")
